# Before `make install' is performed this script should be runnable with
# `make test'. After `make install' it should work as `perl Calculator.t'

#########################

# change 'tests => 1' to 'tests => last_test_to_print';

use Test::More tests => 9;
BEGIN { use_ok('Calculator');
        use_ok('Calculator::EvalCalc');
};

#########################

# Insert your test code below, the Test::More module is use()ed here so read
# its man page ( perldoc Test::More ) for help writing this test script.


my $input = '1+2';
my $expected = '3';
my $tree = parse($input);
is($tree->ceval(),$expected,"suma");

$input = '-1';
$expected = '-1';
$tree = parse($input);
is($tree->ceval(),$expected,"uneg");


$input = '4!';
$expected = '24';
$tree = parse($input);
is($tree->ceval(),$expected,"factorial");

$input = '4^2';
$expected = '16';
$tree = parse($input);
is($tree->ceval(),$expected,"potencia");


$input = '{a=1;a=a}';
$expected = '1';
$tree = parse($input);
is($tree->ceval(),$expected,"asignacion y uso");

$input = 'if 1 then 2';
$expected = '2';
$tree = parse($input);
is($tree->ceval(),$expected,"if sin else");

$input = 'if 0 then 1 else 2';
$expected = '2';
$tree = parse($input);
is($tree->ceval(),$expected,"if con else");

